package io.github.uicdb.et.recipe;

import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import io.github.uicdb.et.ElementalTheory;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.common.util.NeoForgeExtraCodecs;
import net.neoforged.neoforge.registries.NeoForgeRegistries;

import java.util.function.Function;

public abstract class TurnInRecipeHandler {
    public static StreamCodec<RegistryFriendlyByteBuf, TurnInRecipeHandler> STREAM_CODEC = ByteBufCodecs.registry(ElementalTheory.TURN_IN_RECIPE_HANDLE_TYPE).dispatch(TurnInRecipeHandler::getType, TurnInRecipeHandlerType::streamCodec);
    public static MapCodec<TurnInRecipeHandler> CODEC = ElementalTheory.TURN_IN_RECIPE_HANDLE_TYPE_REGISTRY.byNameCodec().dispatchMap("handle_type",
            TurnInRecipeHandler::getType, TurnInRecipeHandlerType::codec
    );

    public abstract ItemStack handleRecipe(ItemStack input);

    protected abstract TurnInRecipeHandlerType<?> getType();
}
